<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: ActiveResource::Connection</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">ActiveResource::Connection</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/vendor/rails/activeresource/lib/active_resource/connection_rb.html">
                vendor/rails/activeresource/lib/active_resource/connection.rb
                </a>
        <br />
                <a href="../../files/vendor/rails/activeresource/lib/active_resource/http_mock_rb.html">
                vendor/rails/activeresource/lib/active_resource/http_mock.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="../Object.html">
                Object
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Class to handle connections to remote web services. This class is used by
<a href="Base.html">ActiveResource::Base</a> to interface with REST
services.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000871">delete</a>&nbsp;&nbsp;
      <a href="#M000870">get</a>&nbsp;&nbsp;
      <a href="#M000868">new</a>&nbsp;&nbsp;
      <a href="#M000873">post</a>&nbsp;&nbsp;
      <a href="#M000872">put</a>&nbsp;&nbsp;
      <a href="#M000867">requests</a>&nbsp;&nbsp;
      <a href="#M000869">site=</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





    <div id="attribute-list">
      <h3 class="section-bar">Attributes</h3>

      <div class="name-list">
        <table>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">format</td>
          <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">site</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        </table>
      </div>
    </div>
      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000868" class="method-detail">
        <a name="M000868"></a>

        <div class="method-heading">
          <a href="#M000868" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(site, format = ActiveResource::Formats[:xml])</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
The <tt>site</tt> parameter is required and will set the <tt>site</tt>
attribute to the URI for the remote resource service.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000868-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000868-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activeresource/lib/active_resource/connection.rb, line 69</span>
69:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">site</span>, <span class="ruby-identifier">format</span> = <span class="ruby-constant">ActiveResource</span><span class="ruby-operator">::</span><span class="ruby-constant">Formats</span>[<span class="ruby-identifier">:xml</span>])
70:       <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">'Missing site URI'</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">site</span>
71:       <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">site</span> = <span class="ruby-identifier">site</span>
72:       <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">format</span> = <span class="ruby-identifier">format</span>
73:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000867" class="method-detail">
        <a name="M000867"></a>

        <div class="method-heading">
          <a href="#M000867" class="method-signature">
          <span class="method-name">requests</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000867-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000867-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activeresource/lib/active_resource/connection.rb, line 62</span>
62:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">requests</span>
63:         <span class="ruby-ivar">@@requests</span> <span class="ruby-operator">||=</span> []
64:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000871" class="method-detail">
        <a name="M000871"></a>

        <div class="method-heading">
          <a href="#M000871" class="method-signature">
          <span class="method-name">delete</span><span class="method-args">(path, headers = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Execute a DELETE request (see HTTP protocol documentation if unfamiliar).
Used to <a href="Connection.html#M000871">delete</a> resources.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000871-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000871-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activeresource/lib/active_resource/connection.rb, line 88</span>
88:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">headers</span> = {})
89:       <span class="ruby-identifier">request</span>(<span class="ruby-identifier">:delete</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">build_request_headers</span>(<span class="ruby-identifier">headers</span>))
90:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000870" class="method-detail">
        <a name="M000870"></a>

        <div class="method-heading">
          <a href="#M000870" class="method-signature">
          <span class="method-name">get</span><span class="method-args">(path, headers = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Execute a GET request. Used to <a href="Connection.html#M000870">get</a>
(find) resources.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000870-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000870-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activeresource/lib/active_resource/connection.rb, line 82</span>
82:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">headers</span> = {})
83:       <span class="ruby-identifier">format</span>.<span class="ruby-identifier">decode</span>(<span class="ruby-identifier">request</span>(<span class="ruby-identifier">:get</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">build_request_headers</span>(<span class="ruby-identifier">headers</span>)).<span class="ruby-identifier">body</span>)
84:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000873" class="method-detail">
        <a name="M000873"></a>

        <div class="method-heading">
          <a href="#M000873" class="method-signature">
          <span class="method-name">post</span><span class="method-args">(path, body = '', headers = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Execute a POST request. Used to create <a
href="Connection.html#M000868">new</a> resources.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000873-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000873-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activeresource/lib/active_resource/connection.rb, line 100</span>
100:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">post</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">body</span> = <span class="ruby-value str">''</span>, <span class="ruby-identifier">headers</span> = {})
101:       <span class="ruby-identifier">request</span>(<span class="ruby-identifier">:post</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">body</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">build_request_headers</span>(<span class="ruby-identifier">headers</span>))
102:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000872" class="method-detail">
        <a name="M000872"></a>

        <div class="method-heading">
          <a href="#M000872" class="method-signature">
          <span class="method-name">put</span><span class="method-args">(path, body = '', headers = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Execute a PUT request (see HTTP protocol documentation if unfamiliar). Used
to update resources.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000872-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000872-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activeresource/lib/active_resource/connection.rb, line 94</span>
94:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">put</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">body</span> = <span class="ruby-value str">''</span>, <span class="ruby-identifier">headers</span> = {})
95:       <span class="ruby-identifier">request</span>(<span class="ruby-identifier">:put</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">body</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">build_request_headers</span>(<span class="ruby-identifier">headers</span>))
96:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000869" class="method-detail">
        <a name="M000869"></a>

        <div class="method-heading">
          <a href="#M000869" class="method-signature">
          <span class="method-name">site=</span><span class="method-args">(site)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Set URI for remote service.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000869-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000869-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activeresource/lib/active_resource/connection.rb, line 76</span>
76:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">site=</span>(<span class="ruby-identifier">site</span>)
77:       <span class="ruby-ivar">@site</span> = <span class="ruby-identifier">site</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">URI</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">site</span> <span class="ruby-operator">:</span> <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">site</span>)
78:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>